#pragma once
#include "Algorithm.h"
#include "SystemView.h"
#include "GradientDescent.h"
#include <list>
#include <map>
#include <string>

using namespace std;

class CAlgo : public Algorithm
{
private:

	double G;
	int L;
	GradientDescent* GD;
	int findOldPlace(ExtentStatsAlgo*);
	int numOfExchanges;
	int exchangeLimit;
	void createSortedExtents(vector<ExtentEntry*>* extents, int timeToDelete, int currentTime);
	void addToSorted(vector<ExtentEntry*>::iterator itList);
	bool alreadyExistsInSortedExtents(ExtentEntry* ex);
	void noMoreExchanges(vector<ExtentStatsAlgo*>::iterator sortIt);
	
public:
	
	CAlgo(SystemView* sys, int sortType, Writer* w, Parser* prs, double constantG, int noTimeSlices, int limit);
	virtual ~CAlgo(void);
	void runAlgo(int iteration);
	double getHitRatio(void);
	double divisionOfPriorityGroup(vector<ExtentStatsAlgo*>* l, int groupNo, int time);

};
